package com.oracle.oa.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.oracle.oa.biz.DepartInfoBiz;
import com.oracle.oa.biz.UserInfoBiz;
import com.oracle.oa.biz.impl.DepartInfoBizImpl;
import com.oracle.oa.biz.impl.UserInfoBizImpl;
import com.oracle.oa.entity.Departinfo;
import com.oracle.oa.entity.Userinfo;

public class DepartinfoAction extends ActionSupport implements SessionAware{
	
	private DepartInfoBiz dbiz;
	UserInfoBiz uBiz=new UserInfoBizImpl();
	private Departinfo d;
	private Departinfo d2;
	Map<String, Object> session;
	
	public String save(){
		//System.out.println(d.getDepartname()+"111111111111111111");
		dbiz.save(d);
		return SUCCESS;		
	}
	
	public String delete(){
//		List<Userinfo> uList=uBiz.getByDeptId(d.getDepartid());
//		for (Userinfo userinfo : uList) {
//			uBiz.delete(userinfo);
//		}
		d=(Departinfo) dbiz.getById(Departinfo.class, d.getDepartid());
		dbiz.delete(d);
		return SUCCESS;		
	}
	public String update(){
		dbiz.update(d2);
	return SUCCESS;		
	}	

	public String one(){
		//System.out.println(d.getDepartid());
		Departinfo dd=(Departinfo) dbiz.getById(Departinfo.class,d.getDepartid());
		session.put("departinfo", dd);
		return "lvhen";
	}
	
	public Departinfo getD() {
		return d;
	}

	public void setD(Departinfo d) {
		this.d = d;
	}

	public void setSession(Map<String, Object> arg0) {
		this.session=arg0;
	}

	public Departinfo getD2() {
		return d2;
	}

	public void setD2(Departinfo d2) {
		this.d2 = d2;
	}

	public DepartInfoBiz getdbiz() {
		return dbiz;
	}

	public void setdbiz(DepartInfoBiz dbiz) {
		this.dbiz = dbiz;
	}

	public DepartInfoBiz getDbiz() {
		return dbiz;
	}

	public void setDbiz(DepartInfoBiz dbiz) {
		this.dbiz = dbiz;
	}
	
	
}
